<template>
  <div>
    <h1>App</h1>
    <div>
      <button @click="comp = 'News'">新闻</button>
      <button @click="comp = 'Play'">娱乐</button>
      <button @click="comp = 'Music'">音乐</button>
    </div>
    <!-- 
      动态组件写法:
        `component`是内置组件,渲染一个“元组件”为动态组件。依 is属性 的值，来决定哪个组件被渲染。
     -->
    <component :is="comp"></component>
  </div>
</template>

<script>
import Music from "@/components/Music";
import News from "@/components/News";
import Play from "@/components/Play";
export default {
  name: "App",
  components: {
    Music,
    News,
    Play,
  },
  data() {
    return {
      comp: "Play",
    };
  },
};
</script>

<style>
</style>